package cn.edu.lzzy.entities;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonIgnore;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

/**
 * 题目实体类
 */

@Entity
public class Question extends  BasicEntity{
    @Transient
    public static final int TYPE_SINGLE=0;//单选
    @Transient
    public static final int TYPE_JUDGE=1;//判断
    @Transient
    public static final int TYPE_MULTI=2;//多选

    private int type;//题型
    private String content;//题目
    private String analysis;//解析

    @OneToMany(cascade = CascadeType.REFRESH,mappedBy = "question")
    private List<Option> options=new ArrayList<>();

    @OneToMany(mappedBy = "question")
    private List<Result> results=new ArrayList<>();

    @ManyToOne
    private Chapter chapter;

    public Question() {
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getAnalysis() {
        return analysis;
    }

    public void setAnalysis(String analysis) {
        this.analysis = analysis;
    }
    @JsonBackReference
    public List<Option> getOptions() {
        return options;
    }

    public void setOptions(List<Option> options) {
        this.options = options;
    }
    @JsonIgnore
    public List<Result> getResults() {
        return results;
    }

    public void setResults(List<Result> results) {
        this.results = results;
    }
    @JsonBackReference
    public Chapter getChapter() {
        return chapter;
    }

    public void setChapter(Chapter chapter) {
        this.chapter = chapter;
    }
}

